<?php

/*
 * This class is used for as Model for Product table 
 */

class Model_Enoria extends Model_Base {

    protected $_name = 'enoria';
    protected $_primaryKey = 'en_id';

    /**
     *  This function is used to get Questions
     * @return null|Zend_Db_Table_Row_Abstract
     */
    public function fetchEnoria($where = "", $limit = "", $offset = "0", $order = 'en_id', $sort = 'ASC') {
        $select = $this->select()
                ->from(array('enoria' => 'enoria'));
        if ($where != '') {
            $select->where($where);
        }
        if ($limit != "") {
            $select->limit($limit, $offset);
        }
        $select->order($order . " " . $sort);

        $data = parent::fetchAll($select);
        if (!empty($data)) {
            $finalArray = array('' => '-- Select Enoria --');
            foreach ($data->toArray() as $_area_type) {
                $finalArray[$_area_type['en_id']] = $_area_type['en_title'];
            }
            return $finalArray;
        } else {
            return array('' => '-- Select Enoria --');
        }
    }
    
    public function fetchAllEnoria($where = "", $limit = "", $offset = "0", $order = 'en_id', $sort = 'ASC') {
        $select = $this->select()
                ->from(array('enoria' => 'enoria'));
        if ($where != '') {
            $select->where($where);
        }
        if ($limit != "") {
            $select->limit($limit, $offset);
        }
        $select->order($order . " " . $sort);

        $data = parent::fetchAll($select);
        if (!empty($data)) {
            
            foreach ($data->toArray() as $_area_type) {
                $finalArray[$_area_type['en_id']] = $_area_type['en_title'];
            }
            return $finalArray;
        } else {
            return array();
        }
    }

}
